import { createApp } from 'vue';
import { createPinia } from 'pinia';
import Antd from 'ant-design-vue';
import 'ant-design-vue/dist/antd.css';
import App from './App.vue';
import router from './router';
import { useUserStore } from '@/stores/user';

const app = createApp(App);
const pinia = createPinia();

// 先使用Pinia
app.use(pinia);
app.use(router);
app.use(Antd);

// 恢复用户状态
const userStore = useUserStore();
if (localStorage.getItem('token')) {
  userStore.token = localStorage.getItem('token') || '';
  userStore.isLoggedIn = true;
  userStore.userInfo.username = localStorage.getItem('username') || '';
  userStore.userInfo.nickname = localStorage.getItem('nickname') || '';
  userStore.userInfo.avatar = localStorage.getItem('avatar') || '';
}

app.mount('#app'); 